
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main(int argc,char *argv[])
{
    int ret = 0;
    int sock = -1;
    struct sockaddr_in servaddr;

    sock = socket(AF_INET,SOCK_STREAM,0);
    memset(&servaddr,0,sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_port = htons(25341);
    servaddr.sin_addr.s_addr = inet_addr("127.0.0.1");

    ret = connect(sock,(struct sockaddr*)&servaddr,sizeof(servaddr));

    if(ret==0)
    {
	char buf[128] = "hello,world and libevent!";
	int len = 0;
	send(sock,buf,strlen(buf),0);
	buf[0]=0;
	len = recv(sock,buf,sizeof(buf),0);
	buf[len] = 0;
	printf("we read:%s\n",buf);
	sleep(7);
	close(sock);
	exit(EXIT_SUCCESS);
    }
    else
    {
	close(sock);
	exit(EXIT_FAILURE);
    }
}

